package com.woniuxy.utils;

import javax.servlet.*;
import java.io.IOException;

public class TimeFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        Filter.super.init(filterConfig);
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        long start = System.currentTimeMillis();
        filterChain.doFilter(servletRequest,servletResponse);//表示放行
        long end =System.currentTimeMillis();
        System.err.println("后端耗时"+(end-start)+"ms");
    }

    @Override
    public void destroy() {
        Filter.super.destroy();
    }
}
